package com.itheima.d2_byte_stream.practice;

import java.io.*;

public class FileCopyPractice {
    public static void main(String[] args) throws IOException {
        File src = new File("day09file-io-app/img1/img2.png");
        File dest = new File("day09file-io-app/img2/img2.png");

        copyFile(src,dest);
    }

    public static void copyFile(File src, File dest) throws IOException {
        FileInputStream fis = new FileInputStream(src);
        FileOutputStream fos = new FileOutputStream(dest);

        int len;
        byte[] buf = new byte[1024];

        while ((len = fis.read(buf)) != -1) {
            fos.write(buf, 0, len);
        }

        fos.close();
        fis.close();
    }
}
